package com.practice;

import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;

public class TestPNG{
    
	public static void main(String[] args) throws IOException {  
        BufferedImage sourceImage = ImageIO.read(new File("e:\\update\\1.png"));  
        BufferedImage dstImage = null;  
        AffineTransform transform = AffineTransform.getScaleInstance(0.6, 0.6);// 返回表示缩放变换的变换  
        AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);  
        dstImage = op.filter(sourceImage, null);  
  
        /********** save到本地 *****************/  
        try {  
            ImageIO.write(dstImage, "png", new File("e:\\update\\1_ok.png"));  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
        /********** save end *****************/  
  
        JTabbedPane tabbedPane = new JTabbedPane();  
        tabbedPane.add("Source Transform", new JLabel(new ImageIcon(sourceImage)));  
        tabbedPane.add("Affine Transform", new JLabel(new ImageIcon(dstImage)));  
  
        JFrame jframe = new JFrame();  
        jframe.setSize(800, 600);  
        jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
        jframe.getContentPane().add(tabbedPane);  
        jframe.setVisible(true);  
  
    }  
}
